/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hera.process.config.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.TableGenerator;

import com.hera.base.domain.BaseDomain;
import com.hera.process.form.domain.FormField;
import com.hera.process.workflow.domain.StageRollup;

/**
 *
 * @author cmontes
 */
@Entity
public class Condition extends BaseDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "CONDITION")
    @TableGenerator(name = "CONDITION", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_id", pkColumnValue = "CONDITION", allocationSize = 1)
    @Column(name = "ID_CONDITION")
    private Long idCondition;
    @Column(name = "VALUE_LEFT")
    private String valueLeft;
    @Column(name = "VALUE_RIGHT")
    private String valueRight;
    @ManyToOne
    @JoinColumn(name="ID_OPERATOR", referencedColumnName = "ID_PARAMETER_DETAIL")
    private ParameterDetail operador;
    private Integer secuence;
    /*@Column(name = "ID_NEXT_CONNECTOR")
    private Long idNextConnector;*/
    @JoinColumn(name="ID_NEXT_CONNECTOR", referencedColumnName = "ID_PARAMETER_DETAIL")
    @ManyToOne
    private ParameterDetail nextConector;
    @JoinColumn(name = "ID_STAGE_ROLLUP", referencedColumnName = "ID_STAGE_ROLLUP")
    @ManyToOne
    private StageRollup stageRollup;
    @ManyToOne
    @JoinColumn(name="ID_TYPEVAL_RIGHT", referencedColumnName = "ID_PARAMETER_DETAIL")
    private ParameterDetail typeRight;
    @ManyToOne
    @JoinColumn(name="ID_TYPEVAL_LEFT", referencedColumnName = "ID_PARAMETER_DETAIL")
    private ParameterDetail typeLeft;
    
    @Column(name = "ID_REFVAL_LEFT")
    private Long idRefValueLeft;
    @Column(name = "ID_REFVAL_RIGHT")
    private Long idRefValueRight;
    
    @ManyToOne
    @JoinColumn(name="ID_REFVAL_LEFT", referencedColumnName = "ID_FIELD", updatable=false,insertable=false)
    private FormField formFieldLeft;
    
    @ManyToOne
    @JoinColumn(name="ID_REFVAL_RIGHT", referencedColumnName = "ID_FIELD", updatable=false,insertable=false)
    private FormField formFieldRight;

    public Condition() {
    }

    public Condition(Long idCondition) {
        this.idCondition = idCondition;
    }

    public Long getIdCondition() {
        return idCondition;
    }

    public void setIdCondition(Long idCondition) {
        this.idCondition = idCondition;
    }

    public String getValueLeft() {
        return valueLeft;
    }

    public void setValueLeft(String valueLeft) {
        this.valueLeft = valueLeft;
    }

    public String getValueRight() {
        return valueRight;
    }

    public void setValueRight(String valueRight) {
        this.valueRight = valueRight;
    }
    
    public ParameterDetail getOperador() {
		return operador;
	}

	public void setOperador(ParameterDetail operador) {
		this.operador = operador;
	}

	public Integer getSecuence() {
        return secuence;
    }

    public void setSecuence(Integer secuence) {
        this.secuence = secuence;
    }

    public ParameterDetail getNextConector() {
		return nextConector;
	}

	public void setNextConector(ParameterDetail nextConector) {
		this.nextConector = nextConector;
	}

	public StageRollup getStageRollup() {
		return stageRollup;
	}

	public void setStageRollup(StageRollup stageRollup) {
		this.stageRollup = stageRollup;
	}

	public ParameterDetail getTypeRight() {
		return typeRight;
	}

	public void setTypeRight(ParameterDetail typeRight) {
		this.typeRight = typeRight;
	}

	public ParameterDetail getTypeLeft() {
		return typeLeft;
	}

	public void setTypeLeft(ParameterDetail typeLeft) {
		this.typeLeft = typeLeft;
	}
	
	public Long getIdRefValueLeft() {
		return idRefValueLeft;
	}

	public void setIdRefValueLeft(Long idRefValueLeft) {
		this.idRefValueLeft = idRefValueLeft;
	}

	public Long getIdRefValueRight() {
		return idRefValueRight;
	}

	public void setIdRefValueRight(Long idRefValueRight) {
		this.idRefValueRight = idRefValueRight;
	}

	public FormField getFormFieldLeft() {
		return formFieldLeft;
	}

	public void setFormFieldLeft(FormField formFieldLeft) {
		this.formFieldLeft = formFieldLeft;
	}

	public FormField getFormFieldRight() {
		return formFieldRight;
	}

	public void setFormFieldRight(FormField formFieldRight) {
		this.formFieldRight = formFieldRight;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (idCondition != null ? idCondition.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof Condition)) {
            return false;
        }
        Condition other = (Condition) object;
        if ((this.idCondition == null && other.idCondition != null) || (this.idCondition != null && !this.idCondition.equals(other.idCondition))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.hera.process.data.domain2.Condition[ idCondition=" + idCondition + " ]";
    }
    
}
